
package client.data;

import client.gui.controls.scrabble.Blokje;
import client.gui.*;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.*;
import java.io.*;
import java.util.*;
import java.util.List;

public class BlokjeTransferable implements Transferable, ClipboardOwner {
    
    public static DataFlavor localStringFlavor ;
    
    public static DataFlavor[] flavors = new DataFlavor[1];
    
    private static List flavorList;
    private Blokje blokje;
    
    public BlokjeTransferable(Blokje b) throws ClassNotFoundException {
        this.localStringFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + Blokje.class.getName());
        this.flavors[0] = BlokjeTransferable.localStringFlavor;
        this.flavorList = Arrays.asList( flavors );
        this.blokje = b;
    }
    
    public synchronized DataFlavor[] getTransferDataFlavors() {
        return flavors;
    }
    
    public boolean isDataFlavorSupported( DataFlavor flavor ) {
        return ( flavorList.contains( flavor ) );
    }
    
    public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
        if (BlokjeTransferable.localStringFlavor.equals(flavor)) {
            return this.blokje;
        } else {
            throw new UnsupportedFlavorException(flavor);
        }
    }
    
    public void lostOwnership(Clipboard clipboard, Transferable contents) {
    }
}
